<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('在管参股基金') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true" @submit.native.prevent>
      <el-form-item :label="$t('项目名称')" prop="dealName">
        <el-input
          v-model="queryParams.dealName"
          :placeholder="$t('项目名称')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" tooltip-effect="darkTable" :data="gpRemanageBfList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目名称')" align="center" prop="dealName" show-overflow-tooltip min-width="180">
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{path:'/deal/home/dealBaseHome',query:{id:scope.row.dealId,dealType: 'bf', gpId:gpId, companyId:scope.row.companyId,menuKey: scope.row.menuKey}}"
            class="link_a"
          >{{ scope.row.companyName }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金名称')" align="center" prop="companyName" show-overflow-tooltip min-width="180">
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{path:'/company/base/companyBaseHome',query:{companyId:scope.row.companyId}}"
            class="link_a"
          >{{ scope.row.companyName }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目负责人')" align="center" prop="dealBase.personChargeName" show-overflow-tooltip min-width="120" />
      <el-table-column :label="$t('预计投资时间')" align="center" prop="dealBase.dateInvestmentEstimate" min-width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dealBase.dateInvestmentEstimate) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('预计投资金额') + $t('金额单位')" align="center" prop="dealBase.amountInvestmentEstimate" min-width="150">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.dealBase.amountInvestmentEstimate, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金认缴规模') + $t('金额单位')" align="center" prop="subscribeScale" min-width="150">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.subscribeScale, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金实缴规模') + $t('金额单位')" align="center" prop="paidInScale" min-width="150">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.paidInScale, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('关注等级')" align="center" prop="dealBase.levelConcern" :formatter="levelConcernFormat" show-overflow-tooltip min-width="150" />
      <el-table-column :label="$t('基金成立日')" align="center" prop="fundSetTime" min-width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.fundSetTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金投资类型')" align="center" prop="investType" :formatter="fundInvestTypFormat" show-overflow-tooltip min-width="120" />
      <el-table-column :label="$t('基金类型')" align="center" prop="fundType" :formatter="fundTypeFormat" show-overflow-tooltip min-width="120" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { findBfListByGpId } from '@/api/bf/base/bfBase'
export default {
  data() {
      return {
          // 遮罩层
          loading: true,
          // 总条数
          total: 0,
          // 在管基金表格数据
          gpRemanageBfList: [],
          // 关注等级
          levelConcernOptions: [],
          // 基金投资类型
          fundInvestTypeOptions: [],
          gpId: this.$route.query.gpId,
          // 基金类型字典
          fundTypeOptions: [],
          // 弹出层标题
          title: '在管基金',
          // 是否显示弹出层
          formOpen: false,
          // 查询参数
          queryParams: {
              manageCompany: this.$route.query.gpId,
              dealName: undefined,
              pageNum: 1,
              pageSize: 10
          },
          // 表单参数
          form: {},
          // 表单校验
          rules: {}
      }
  },
  created() {
      // 关注等级
      this.getDicts('level_concern').then(response => {
        this.levelConcernOptions = response.data
      })
      // 基金投资类型
      this.getDicts('fund_invest_type').then(response => {
        this.fundInvestTypeOptions = response.data
      })
      // 基金类型字典
      this.getDicts('fund_type').then(response => {
        this.fundTypeOptions = response.data
      })
      this.getList()
  },
  methods: {
    /** 查询在管基金列表 */
    getList() {
        this.loading = true
        findBfListByGpId(this.queryParams).then(response => {
            this.gpRemanageBfList = response.rows
            this.total = response.total
            this.loading = false
        })
    },
    // 关注等级
    levelConcernFormat(row) {
      return this.selectDictLabel(this.levelConcernOptions, row.dealBase.levelConcern)
    },
    // 基金投资类型
    fundInvestTypFormat(row) {
      return this.selectDictLabel(this.fundInvestTypeOptions, row.investType)
    },
    // 基金类型字典
    fundTypeFormat(row) {
      return this.selectDictLabel(this.fundTypeOptions, row.fundType)
    },
    // 表单重置
    reset() {
        this.form = {
            id: undefined,
            manage_company: this.$route.query.gpId,
            dealName: undefined,
            companyName: undefined,
            personCharge: undefined,
            dateInvestmentEstimate: undefined,
            amountInvestmentEstimate: undefined,
            subscribeScale: undefined,
            paidInScale: undefined,
            levelConcern: undefined,
            fundSetTime: undefined,
            investType: undefined,
            fundType: undefined,
            remark: undefined,
            createBy: undefined,
            createTime: undefined,
            updateBy: undefined,
            updateTime: undefined,
            delFlag: undefined
        }
        this.resetForm('form')
    },
    /** 搜索按钮操作 */
    queryHandle() {
        this.queryParams.pageNum = 1
        this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
        this.resetForm('queryForm')
        this.queryHandle()
    }
  }
}
</script>
